package com.example.appointment.activity;

import android.os.Bundle;
import android.view.Gravity;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;

import com.example.appointment.R;
import com.example.appointment.widget.BottomSwitchPopWindows;
import com.example.appointment.widget.CircleImageView;

import butterknife.Bind;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * 完善资料
 * Created by Admin on 2016/10/7.
 */

public class PerfectInformationActivity extends BaseActivity {

    @Bind(R.id.information_left_btn)
    ImageView informationLeftBtn;
    @Bind(R.id.information_title)
    TextView informationTitle;
    @Bind(R.id.head_img)
    CircleImageView headImg;
    @Bind(R.id.information_name)
    EditText informationName;
    @Bind(R.id.information_sax)
    TextView informationSax;
    @Bind(R.id.information_age)
    TextView informationAge;
    @Bind(R.id.information_signature)
    EditText informationSignature;
    @Bind(R.id.registered_success_btn)
    Button registeredSuccessBtn;

    private BottomSwitchPopWindows bottomSwitchPopWindows;
    private View parentView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setnotificationColore(R.color.maincolor);//設置导航栏顔色
        parentView = getLayoutInflater().inflate(R.layout.activity_perfect_information,null,false);
        setContentView(parentView);

        ButterKnife.bind(this);
    }

    @OnClick({R.id.information_left_btn, R.id.head_img, R.id.information_sax, R.id.information_age, R.id.registered_success_btn})
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.information_left_btn:
                finish();
                break;
            case R.id.head_img:
                //点击头像
                break;
            case R.id.information_sax:
                //点击性别
                createBottomPopWindows(0,informationSax.getText().toString());
                break;
            case R.id.information_age:
                //点击年龄
                createBottomPopWindows(1,informationAge.getText().toString());
                break;
            case R.id.registered_success_btn:
                //注册完成
                break;
        }
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        ButterKnife.unbind(this);
    }

    /**
     * 创建底部选择弹窗
     * @param type 0 性别 1 年龄
     * @param item 当前选择的item 默认传空
     */
    private void createBottomPopWindows(final int type, String item){
//        if (bottomSwitchPopWindows==null){
            bottomSwitchPopWindows = new BottomSwitchPopWindows(PerfectInformationActivity.this);
//        }

        bottomSwitchPopWindows.SwitchWheelView(type,item);

        bottomSwitchPopWindows.setOnCancelClick(new BottomSwitchPopWindows.OnCancelClick() {
            @Override
            public void onCancelClick() {
                bottomSwitchPopWindows.dismiss();
            }
        });

        bottomSwitchPopWindows.setOnEnterClick(new BottomSwitchPopWindows.OnEnterClick() {
            @Override
            public void onEnterClick() {
                if (type==0){
                    informationSax.setText(bottomSwitchPopWindows.getSwitchItems());
                }else{
                    informationAge.setText(bottomSwitchPopWindows.getSwitchItems());
                }

                bottomSwitchPopWindows.dismiss();
            }
        });

        bottomSwitchPopWindows.showAtCenter(parentView);
    }
}
